package com.filetest;

import java.io.File;

public class fileIO2 {
    public static void main(String[] args) {
        ListFiles("F:");
    }
    public static void ListFiles(String path){
        File dir=new File(path);
        if(!dir.exists()||!dir.isDirectory()) return;
        File[] files=dir.listFiles();
        for (int i = 0; i < files.length; i++) {
            if (files[i].isFile()) {
                System.out.println(path+"\\"+files[i].getName()+"\t"+files[i].length());
            }else{
                System.out.println(path+"\\"+files[i].getName()+"\t<dir>");
                ListFiles(files[i].getPath());
            }
        }
    }
}
